LL power(LL x, int p){ LL cnt = 1; while (p) { if (p & 1) cnt = cnt * x % MOD; x = x * x % MOD; p >>= 1; } return cnt; }
int N, M;
int father[MAXN][20]; intfind(int x, int j){ return father[x][j] == x ? x : father[x][j] = find (father[x][j], j); } voidmerge(int x, int y, int j){ int fx = find (x, j), fy = find (y, j); father[fx][j] = fy; } voidpushdown(){ for (int j = 18; j >= 1; j --) for (int i = 1; i + (1 << j) - 1 <= N; i ++) { int fx = find (i, j); merge (i, fx, j - 1); merge (i + (1 << (j - 1)), fx + (1 << (j - 1)), j - 1); } }
intgetnum(){ int num = 0; char ch = getchar ();
while (! isdigit (ch)) ch = getchar (); while (isdigit (ch)) num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();
return num; }
intmain(){ N = getnum (), M = getnum (); for (int i = 1; i <= N; i ++) for (int j = 0; j <= 18; j ++) father[i][j] = i; for (int i = 1; i <= M; i ++) { int l1 = getnum (), r1 = getnum (); int l2 = getnum (), r2 = getnum (); int p = 0; for (int j = 18; j >= 0; j --) if (l1 + p + (1 << j) - 1 <= r1) { merge (l1 + p, l2 + p, j); p += (1 << j); } } pushdown (); int group = 0; for (int i = 1; i <= N; i ++) if (find (i, 0) == i) group ++; LL ans = 9ll * power (10ll, group - 1) % MOD; cout << ans << endl;